//
//  View2Controller.m
//  文印室
//
//  Created by KL on 17/2/21.
//  Copyright © 2017年 KM. All rights reserved.
//

#import "View2Controller.h"
#import "ViewController.h"
#import "BumenView.h"
#import "DataChe.h"
#import "YewTableView.h"

@interface View2Controller ()
{
    NSArray *data;
}
@end

@implementation View2Controller

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"首页";
    data = @[
             @"部门列表",
             @"业务列表",
             @"部门列表",
             @"项目列表",
             @"浏览列表",
             @"用户列表",
             ];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"注销" style:UIBarButtonItemStylePlain target:self action:@selector(onEnd:)];
}

- (void)onEnd:(id)sender
{
    [DataChe getWithParam:@"http://a.xl18z.cn/api/logout" complete:^(NSDictionary *d) {
        UIViewController *con = [self.storyboard instantiateViewControllerWithIdentifier:@"nav"];
        [self presentViewController:con animated:YES completion:nil];
    }];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return data.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
    cell.textLabel.text = data[indexPath.row];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0)
    {
        BumenView *bm = [self.storyboard instantiateViewControllerWithIdentifier:@"bum"];
        [self.navigationController pushViewController:bm animated:YES];
    }
    else if(indexPath.row == 1)
    {
        YewTableView *yw =[self.storyboard instantiateViewControllerWithIdentifier:@"yew"];
        [self.navigationController pushViewController:yw animated:YES];
    }
}

@end
